#ifndef WBSECSVC_EAPOL_KEY_MESSAGE_INC__
#define WBSECSVC_EAPOL_KEY_MESSAGE_INC__

//#include <windows.h>
//#include "STLFunction.h"
//#include "sysdef.h"

//#define BIT(x)      (1 << x)

// ref [IEEE 802.11i/D3.1 clause 8.4.1.1]

// 802.1x Packet Type field
enum { 
    PT_EAP_PACKET           = 0,
    PT_EAPOL_START          = 1,
    PT_EAPOL_LOGOFF         = 2,
    PT_EAPOL_KEY            = 3,
    PT_EAPOL_EN_ASF_ALERT   = 4,
};

// 802.1X Protocol Version field
enum {
    PV_EAPOL_1 = 1
};

#pragma pack(1)
/*
typedef struct _IEEE8021X_HEADER
{
    UCHAR    PV;
    UCHAR    PT;
    UCHAR   PBL;
} IEEE8021X_HEADER, *PIEEE8021X_HEADER;
*/

typedef struct _EAP_HEADER
{
    UCHAR    PV;		//verson
    UCHAR    PT;		//type
    USHORT    PBL;		//length
}__ALIGN_PACK__  EAP_HEADER, *PEAP_HEADER;

typedef EAP_HEADER IEEE8021X_HEADER;
#pragma pack()


#define MASK_KEY_DESC_VER_NUM   (BIT(0) | BIT(1) | BIT(2))

#define KEY_DESC_VERSION_NUM(ki)    ((ki) & MASK_KEY_DESC_VER_NUM)

enum {
    EAPOL_KEY_INFO_VERSION_1    = 1,
    EAPOL_KEY_INFO_VERSION_2    = 2,
};

enum {
    EAPOL_KEY_DESC_TYPE = 0xFE,
    EAPOL_KEY_DESC_TYPE_WPA2 = 0x02  // sky add for wpa2 2005.4.20
};

#pragma pack(1)
typedef struct _EAPOL_KEY
{
    UCHAR    Desc;  
    USHORT    KeyInfo;
    USHORT    KeyLen;
    UCHAR    ReplayCounter[8];
    UCHAR    KeyNonce[32];
    UCHAR    KeyIV[16];
    UCHAR    KeyRSC[8];
    UCHAR    KeyID[8];
    UCHAR    KeyMIC[16];
    USHORT    KeyMaterialLen;
    // BYTE    KeyData[1];
    
}__ALIGN_PACK__  EAPOL_KEY, *PEAPOL_KEY;
#pragma pack()


//************************************************************
//Ethernet Packet
//************************************************************

//EPAOL Frame

//|---------|--------|--------|--------|--------|--------|--//
//|DA		|SA		 |Eth Type|Version |P Type	|P Body L|--//
//|---------|--------|--------|--------|--------|--------|--//
//   6        6        2          1         1     2

#define EAPOL_802_1X_PACKET     0x8e88

typedef struct _ETH_PACKET
{
    UCHAR   DA[6];
    UCHAR   SA[6];
    USHORT  TL;
}__ALIGN_PACK__  ETH_PACKET, *PETH_PACKET;

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//Added by WangJS 2006.8.11
enum{
	GROUP_FRAME_TYPE,
	PAIRWISE_FRAME_TYPE
};
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#endif // WBSECSVC_EAPOL_KEY_MESSAGE_INC__
// end of file


